﻿LocalMemory = function (methodState) {
    this.methodState = methodState;
    this.data = [];
};

LocalMemory.prototype.Set = function (location, dataValue) {
    this.data[location] = dataValue;
    this.methodState.vm.onMemoryChanged();
};

LocalMemory.prototype.Get = function (location) {
    this.checkLocalIndex(location);
    return this.data[location];
};

LocalMemory.prototype.Length = function () {
    return this.data.length;
};

LocalMemory.prototype.checkLocalIndex = function (index) {
    if (isNaN(index) || index < 0 || index >= this.data.length)
        throw "IndexOutOfRangeException";
};

